package com.hbms.business.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.hbms.common.annotation.Log;
import com.hbms.common.core.controller.BaseController;
import com.hbms.common.core.domain.AjaxResult;
import com.hbms.common.enums.BusinessType;
import com.hbms.business.domain.HotelbmsUsereducational;
import com.hbms.business.service.IHotelbmsUsereducationalService;
import com.hbms.common.utils.poi.ExcelUtil;
import com.hbms.common.core.page.TableDataInfo;

/**
 * 用户学历Controller
 * 
 * @author zl
 * @date 2024-04-10
 */
@RestController
@RequestMapping("/business/usereducational")
public class HotelbmsUsereducationalController extends BaseController
{
    @Autowired
    private IHotelbmsUsereducationalService hotelbmsUsereducationalService;

    /**
     * 查询用户学历列表
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:list')")
    @GetMapping("/list")
    public TableDataInfo list(HotelbmsUsereducational hotelbmsUsereducational)
    {
        startPage();
        List<HotelbmsUsereducational> list = hotelbmsUsereducationalService.selectHotelbmsUsereducationalList(hotelbmsUsereducational);
        return getDataTable(list);
    }

    /**
     * 导出用户学历列表
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:export')")
    @Log(title = "用户学历", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, HotelbmsUsereducational hotelbmsUsereducational)
    {
        List<HotelbmsUsereducational> list = hotelbmsUsereducationalService.selectHotelbmsUsereducationalList(hotelbmsUsereducational);
        ExcelUtil<HotelbmsUsereducational> util = new ExcelUtil<HotelbmsUsereducational>(HotelbmsUsereducational.class);
        util.exportExcel(response, list, "用户学历数据");
    }

    /**
     * 获取用户学历详细信息
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:query')")
    @GetMapping(value = "/{userEducationalId}")
    public AjaxResult getInfo(@PathVariable("userEducationalId") Long userEducationalId)
    {
        return success(hotelbmsUsereducationalService.selectHotelbmsUsereducationalByUserEducationalId(userEducationalId));
    }

    /**
     * 新增用户学历
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:add')")
    @Log(title = "用户学历", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HotelbmsUsereducational hotelbmsUsereducational)
    {
        return toAjax(hotelbmsUsereducationalService.insertHotelbmsUsereducational(hotelbmsUsereducational));
    }

    /**
     * 修改用户学历
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:edit')")
    @Log(title = "用户学历", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HotelbmsUsereducational hotelbmsUsereducational)
    {
        return toAjax(hotelbmsUsereducationalService.updateHotelbmsUsereducational(hotelbmsUsereducational));
    }

    /**
     * 删除用户学历
     */
    @PreAuthorize("@ss.hasPermi('business:usereducational:remove')")
    @Log(title = "用户学历", businessType = BusinessType.DELETE)
	@DeleteMapping("/{userEducationalIds}")
    public AjaxResult remove(@PathVariable Long[] userEducationalIds)
    {
        return toAjax(hotelbmsUsereducationalService.deleteHotelbmsUsereducationalByUserEducationalIds(userEducationalIds));
    }
}
